// search的小仓库
import { reqGetSearchInfo } from "@/api"
// 仓库存储数据的地方
const state = {
  searchList: {}
}
// 修改state的唯一手段
const mutations = {
  SEARCHLIST(state, searchList) {
    state.searchList = searchList
  }
}
// 处理action,可以书写自己的业务逻辑
const actions = {
  async getSearchList({ commit }, params = {}) {
    let result = await reqGetSearchInfo(params)
    if (result.code == 200) {
      commit('SEARCHLIST', result.data)
    }
  }
}
// 计算属性,用于简化仓库数据,获取数据更加方便
const getters = {
  goodsList(state) {
    return state.searchList.goodsList || []
  },
  trademarkList(state) {
    return state.searchList.trademarkList || []
  },
  attrsList(state) {
    return state.searchList.attrsList || []
  }
}

export default {
  state,
  mutations,
  actions,
  getters
}
